home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 483 / mkrscsrc / event.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-29  |  4.1 KB  |  164 lines

  1. #include "stdio.h"
  2. #include "gemdefs.h"
  3. #include "obdefs.h"
  4. #include "osbind.h"
  5. #include "mkrsc.h"
  6. #include "globals.h"
  7.  
  8.  
  9. int TaskMaster()
  10. {
  11.     windowptr thewin;
  12.  
  13.     int event;            /* The event code.                    */
  14.     int button = TRUE;    /* desired Button state                */
  15.     int mousebutton;    /* The state of the mouse button    */
  16.     int    message[8];        /* Event message buffer.            */
  17.     int mousex, mousey;
  18.     int keycode;        /*  The code for the key pressed.    */
  19.     int keymods;        /*  The state of the keyboard modifiers.
  20.                             (shift, ctrl, etc). */
  21.     int clicks;            /*    The number of mouse clicks that occurred in the 
  22.                             given time. */
  23.     OBJECT *inwinptr;
  24.     int i, select;
  25.  
  26.     do {
  27.     if(thefrontwin)
  28.     {        inwinptr = thefrontwin->inwindow->objt;
  29.             select = FALSE;
  30.  
  31.         for(i=0;i<(thefrontwin->inwindow->count + 1);i++)
  32.             if(inwinptr[i].ob_state & SELECTED)
  33.                 select = TRUE;
  34.  
  35.         if (thefrontwin->inwindow == &thefrontwin->maintree)
  36.             {    onleft = treicont;
  37.                 wind_set(0,WF_NEWDESK,hightreadr,lowtreadr, 0);
  38.                 if(tempm == NULL)
  39.                     mkrscmnu[PASTE].ob_state = DISABLED;
  40.                 else
  41.                     mkrscmnu[PASTE].ob_state = NORMAL;
  42.             }
  43.             else
  44.             {    if(thefrontwin->inwindow->kind[0] == TMENU)
  45.                 {    onleft = mnuicont;
  46.                     wind_set(0,WF_NEWDESK,highmnuadr,lowmnuadr, 0);
  47.                 }
  48.                 else
  49.                 {    onleft = obicont;
  50.                     wind_set(0,WF_NEWDESK,highobadr,lowobadr, 0);
  51.                     mkrscmnu[SNAP].ob_state = NORMAL;
  52.                     mkrscmnu[SALL].ob_state = NORMAL;
  53.                     mkrscmnu[SSEL].ob_state = NORMAL;
  54.                     if(select)
  55.                         mkrscmnu[SORT].ob_state = NORMAL;
  56.                 }
  57.  
  58.                 if(spaste)
  59.                     mkrscmnu[PASTE].ob_state = NORMAL;
  60.                 else
  61.                     mkrscmnu[PASTE].ob_state = DISABLED;
  62.             }
  63.  
  64.             if (select)
  65.             {    mkrscmnu[CUT].ob_state = NORMAL;
  66.                 mkrscmnu[COPY].ob_state = NORMAL;
  67.                 mkrscmnu[ERASE].ob_state = NORMAL;
  68.                 mkrscmnu[NAM].ob_state = NORMAL;
  69.             }
  70.             else
  71.             {    mkrscmnu[CUT].ob_state = DISABLED;
  72.                 mkrscmnu[COPY].ob_state = DISABLED;
  73.                 mkrscmnu[ERASE].ob_state = DISABLED;
  74.                 mkrscmnu[SORT].ob_state = DISABLED;
  75.                 mkrscmnu[NAM].ob_state = DISABLED;
  76.             }
  77.     }    /* end of if(thefrontwin)    */
  78.     else
  79.     {    mkrscmnu[CUT].ob_state = DISABLED;
  80.         mkrscmnu[COPY].ob_state = DISABLED;
  81.         mkrscmnu[ERASE].ob_state = DISABLED;
  82.         mkrscmnu[PASTE].ob_state = DISABLED;
  83.         mkrscmnu[SNAP].ob_state = DISABLED;
  84.         mkrscmnu[SALL].ob_state = DISABLED;
  85.         mkrscmnu[SSEL].ob_state = DISABLED;
  86.         mkrscmnu[SORT].ob_state = DISABLED;
  87.     }
  88.     
  89.  
  90.  
  91.         event = evnt_multi(
  92.             MU_MESAG | MU_BUTTON | MU_KEYBD,   /* set messages to respond to. */
  93.             2,                /* Time frame for events.                    */
  94.             1,                /* Keyboard Event mask.                        */
  95.             button,            /* desired key state                        */
  96.             0, 0, 0, 0, 0,    /* rectangle one information (ignored)        */
  97.             0, 0, 0, 0, 0,    /* rectangle two information (ignored)        */
  98.             message,        /* The message buffer                         */
  99.             0, 0,            /* Number of Ticks for Timer event.         */
  100.             &mousex,        /* The x-coordinate of the mouse at event.  */
  101.             &mousey,        /* The y-coordinate of the mouse at event.  */
  102.             &mousebutton,    /* The state of the mouse buttons at event. */
  103.             &keymods,        /* The state of the keyboard modifiers.     */
  104.             &keycode,        /* The key code for the key pressed.        */
  105.             &clicks            /* The number of times the event occurred    */
  106.         );
  107.  
  108.  
  109.         if (event & MU_MESAG) {
  110.             switch (message[0]) {
  111.                 /*
  112.                     Window Support
  113.                 */
  114.                 case WM_REDRAW:
  115.        do_redraw(message);
  116.         break;
  117.                 case WM_TOPPED:
  118.                     wind_set(message[3], WF_TOP, 0, 0, 0, 0);
  119.                     break;
  120.                 case WM_FULLED:
  121.                 case WM_ARROWED:
  122.                 case WM_HSLID:
  123.                 case WM_VSLID:
  124.                 case WM_MOVED:
  125.                 case WM_SIZED:       break;
  126.  
  127.                 case WM_NEWTOP:        
  128.                     wind_set(message[3], WF_TOP, 0, 0, 0, 0);
  129.                     break;
  130.                 case WM_CLOSED:        message[3] = FILE;
  131.                                     message[4] = CLOSE;
  132.                                     do_menu(message);
  133.                     break;
  134.  
  135.                 /*
  136.                     Menu Support
  137.                 */
  138.                 case MN_SELECTED:
  139.                     do_menu(message);
  140.                     button ^= TRUE;
  141.  
  142.                 break;
  143.  
  144.                 /*
  145.                     Desk Accessory Support
  146.                 */
  147.                 case AC_OPEN:
  148.                 case AC_CLOSE:
  149.                 break;
  150.             }
  151.         }
  152.  
  153.         if (event & MU_BUTTON)
  154.                 if(button)
  155.                     do_button(mousex, mousey, clicks);
  156.                 button ^= TRUE;
  157.  
  158.         if (event & MU_KEYBD)
  159.             do_update(keycode,keymods);
  160.  
  161.     } while(1);
  162. }
  163.  
  164.